{include file="/common/_meta"}
</head>
<body>
{include file="/common/top"}

<div class="main-container container-fluid">
    <div class="page-container">
        <!-- Page Sidebar -->
       {include file="/common/list"}
        <!-- Page Content -->
        <div class="page-content">

            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                   <li>
                        <a href="#">系统</a>
                    </li>
                    <li>
                        <a href="{:url('goods/lst')}">商品库存管理</a>
                    </li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->

            <!-- Page Body -->
            <div class="page-body">

                <div class="row">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <form action="" method="post">
                        <div class="widget">
                            <div class="widget-body">
                                <div class="flip-scroll">
                                    <table class="table table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                {volist name='radioAttrRed' id='color'}
                                                <th class="text-center">{$key}</th>
                                                {/volist}
                                                <th class="text-center">库存量</th>
                                                <th class="text-center" width="10%">操作</th>
                                            </tr>
                                        </thead>

                                        <tbody>
                                            <?php if($productstr):
                                                foreach($productstr as $k0=>$v0):
                                                
                                            ?>
                                            <tr>
                                                <?php foreach($radioAttrRed as $k=>$v):?>
                                                <td align="center">
                                                    
                                                    <select name="product_attr[{$k}][]">
                                                        <option>请选择</option>
                                                        <?php foreach($v as $k1=>$v1):
                                                            $arr = explode(',',$v0['prod_goods_attr']);
                                                            if(in_array($v1['gsattr_id'],$arr)){
                                                                $selected = 'selected="selected"';
                                                            }else{
                                                                $selected = '';
                                                            }
                                                        ?>
                                                        <option value="<?php echo $v1['gsattr_id']?>" <?php echo $selected?>><?php echo $v1['gsattr_value']; ?></option>
                                                        <?php endforeach;?>
                                                    </select>
                                                    
                                                </td>
                                                <?php endforeach;?>
                                                <td align="center"><input type="text" name="product_num[]" style="text-align: center;" value="<?php echo $v0['prod_goods_num']?>"></td>
                                                <td align="center"><a href="javascript:;" onClick="addr(this)" class="btn btn-sm btn-azure btn-addon"><?php if($k0 == 0) {echo '+';} else {echo '-';}?></a></td>
                                            </tr>
                                            <?php endforeach; else:?>
                                            <tr>
                                                <?php foreach($radioAttrRed as $k=>$v):?>
                                                <td align="center">
                                                    
                                                    <select name="product_attr[{$k}][]">
                                                        <option>请选择</option>
                                                        <?php foreach($v as $k1=>$v1):?>
                                                        <option value="<?php echo $v1['gsattr_id']?>"><?php echo $v1['gsattr_value']; ?></option>
                                                        <?php endforeach;?>
                                                    </select>
                                                    
                                                </td>
                                                <?php endforeach;?>
                                                <td align="center"><input type="text" name="product_num[]" style="text-align: center;"></td>
                                                <td align="center"><a href="javascript:;" onClick="addr(this)" class="btn btn-sm btn-azure btn-addon" >+</a></td>
                                            </tr>
                                            <?php endif;?>
                                        </tbody>

                                    </table>
                                </div>

                                <div class="flip-scroll col-sm-offset-5" style="margin-top:10px ">
                                    <button type="submit" class="btn btn-default">保存信息</button>
                                </div>
                      
                            </div>
                        </div>
                        </form>
                    </div>
                </div>

            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
	</div>	
</div>

<script type="text/javascript">
    function addr(o){
        var tr=$(o).parent().parent();
        if ($(o).html() == '+') {
            var newtr=tr.clone();
            newtr.find('a').html('-');
            tr.after(newtr);
        }else{
            tr.remove();
        }
    }
</script>
</body>
</html>

